// SPDX-License-Identifier: GPL-2.0-or-later
// Copyright (c) 2023 Yevhen Babiichuk (DustDFG)

#ifndef _VIEW_HPP_
#define _VIEW_HPP_

#include <SFML/System/Clock.hpp>

#include <SFML/Graphics/RenderWindow.hpp>

#include <string>
#include <optional>

#include <SFML/Graphics.hpp>

#include <DotSort/View/IView.hpp>
#include <Abracadabra/View/Theme.hpp>
#include <Abracadabra/View/Tube.hpp>

namespace View
{

class View : public IView, public sf::Drawable
{
	private:
		mutable std::vector<Tube> gridOfDots;

		virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const override;

		Theme* theme;

		void drawTubeTextures(sf::RenderTarget& target, sf::RenderStates states) const;

		sf::RenderWindow* window;

	public:
		View(uint8_t tubeSize, uint8_t tubeCount, sf::RenderWindow* window);
		virtual ~View();

		void updateTube(uint8_t tubeIndex, const std::vector<uint8_t>& dots) override;

		void draw() const override;

		std::optional<uint8_t> getTubeIndex(sf::Event& event) const;
};

}

#endif
